home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / pour.dxr / 00009_Hour hand behavior.ls < prev    next >
Encoding:
Text File  |  2000-03-23  |  1.1 KB  |  48 lines

  1. property pSpr, pCenter, pRadius
  2.  
  3. on beginSprite me
  4.   pSpr = sprite(me.spriteNum)
  5.   pCenter = sprite(me.spriteNum - 1).loc
  6.   pRadius = 15
  7. end
  8.  
  9. on mUpdate me, ounces
  10.   repeat while ounces >= 12
  11.     ounces = ounces - 12
  12.   end repeat
  13.   percent = ounces / 12.0
  14.   theta = percent * 6.28319000000000027
  15.   pSpr.member.shapeType = #line
  16.   if percent <= 0.25 then
  17.     direction = 1
  18.   else
  19.     if (percent > 0.25) and (percent <= 0.5) then
  20.       direction = 0
  21.     else
  22.       if (percent > 0.5) and (percent <= 0.75) then
  23.         direction = 1
  24.       else
  25.         if (percent > 0.75) and (percent <= 1.0) then
  26.           direction = 0
  27.         end if
  28.       end if
  29.     end if
  30.   end if
  31.   pSpr.member.lineDirection = direction
  32.   newVertex = pCenter + point(integer(pRadius * sin(theta)), -integer(pRadius * cos(theta)))
  33.   if abs(pCenter[1] - newVertex[1]) <= 1 then
  34.     newVertex[1] = newVertex[1] + 3
  35.     pSpr.member.shapeType = #rect
  36.   else
  37.     if abs(pCenter[2] - newVertex[2]) <= 1 then
  38.       newVertex[2] = newVertex[2] + 3
  39.       pSpr.member.shapeType = #rect
  40.     end if
  41.   end if
  42.   pSpr.rect = rect(pCenter, newVertex)
  43. end
  44.  
  45. on endSprite me
  46.   pSpr.member.shapeType = #line
  47. end
  48.